import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  // 通配符路由，捕获所有未匹配的路由
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'  // 重定向到首页
  },
  {
    path: '/dealer-contact',
    name: 'dealerContact',
    component: () => import('../views/DealerContactView.vue'),
    props: route => ({ carModel: route.query.carModel })
  },
  {
    path: '/',
    name: 'home',
    component: () => import('../views/Index.vue')
  },
  {
    path: '/explore',
    name: 'explore',
    component: () => import('../views/ExploreView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/shop',
    name: 'Shop',
    component: () => import('../views/ShopView.vue')
  },
  {
    path: '/advisor',
    name: 'carAdvisor',
    component: () => import('../views/caradvisorview.vue')
  },
  {
    path: '/services',
    name: 'Services',
    component: () => import('../views/ServicesView.vue')
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/AboutView.vue')
  },
  {
    path: '/config/:modelId',
    name: 'config',
    component: () => import('../views/ConfigView.vue')
  },
  {
    path: '/news',
    name: 'news',
    component: () => import('../views/NewsView.vue')
  },
  {   
    path: '/car/:modelId/reviews',
    name: 'carReviews',
    component: () => import('../views/CarReviewView.vue')  },
  {
    path: '/user/info',
    name: 'userInfo',
    component: () => import('../views/UserInfoView.vue')
  },
  {
    path: '/user/profile',
    name: 'userProfile',
    component: () => import('../views/UserProfileView.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router